package com.vt.admin.controller;


import com.vt.admin.api.entity.SysLog;
import com.vt.admin.api.entity.SysLoginLog;
import com.vt.admin.service.SysLogService;
import com.vt.common.core.util.R;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 日志
 */
@RestController
@RequestMapping("/log")
@AllArgsConstructor
public class LogController {

    private final SysLogService sysLogService;

    @ApiOperation("插入日志")
    @PostMapping
    public R<Boolean> save(@Valid @RequestBody SysLog sysLog) {
        return new R(sysLogService.save(sysLog));
    }

    @ApiOperation("插入登录日志")
    @PostMapping("/login_log")
    public R<Boolean> saveLoginLog(@Valid @RequestBody SysLoginLog logVo) {
        return new R(sysLogService.saveLoginLog(logVo));
    }
}
